<template>
  <div v-loading="loading">
    <div class="top display-flex justify-content align-items">
      新闻资讯
    </div>
    <div class="content">
      <div class="title"></div>
      <div class="news">
        <el-card shadow="hover">
            <div class="message">
              <p class="">{{newsMess.name}}</p>
              <p>{{newsMess.create_time_text}}</p>
              <p class="">{{newsMess.description}}</p>
            </div>
            <img :src="newsMess.image" :alt="newsMess.name" title=""/>
        </el-card>
      </div>
     </div>
   </div>
</template>

<script>
  export default {
    name: "newsMess",
    data() {
      return {
        loading: false,
        newsID: 0,
        newsMess:[],
      }
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
      getNewsMess() {
        // 取到路由带过来的参数
        this.newsID = this.$route.params.id;
        if(!this.newsID){
          this.newsID = localStorage.getItem('newsID');
          //没有传递ID,本地缓存也没有ID
          if(!this.newsID){
            this.$router.push('/news');
          }
        }else {
          localStorage.setItem('newsID',this.newsID);
        }
        let that = this;
        this.$http
          .post(this.$api.default.ZXFL,{id : that.newsID})
          .then(res => {
            console.log('数据', res);
            res.data.image = that.$api.default.url_ + res.data.image;
            res.data.create_time_text = res.data.create_time_text.substring(0,10);
            that.newsMess = res.data

          }).catch(error => {
          })
          .then(() => {
          });
      },
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created() {
      this.getNewsMess()
    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {}, //生命周期 - 创建之前
    beforeCreate() {},
    //生命周期 - 挂载之前
    beforeMount() {},
    //生命周期 - 更新之前
    beforeUpdate() {},
    //生命周期 - 更新之后
    updated() {},
    //生命周期 - 销毁之前
    beforeDestroy() {},
    //生命周期 - 销毁完成
    destroyed() {},
    //如果页面有keep-alive缓存功能，这个函数会触发
    activated() {},
  }
</script>

<style scoped>
  .top{
    height: 500px;
    min-width: 1200px;
    background: url("../assets/image/banner5.png") no-repeat;
    background-position: center center;
    background-size: cover;
    box-sizing: border-box;
    font-size: 50px;
    color: #FFFFFF;
  }
  .top p{
    font-size: 50px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #FFFFFF;
    line-height: 60px;
    text-align: center;
    margin-bottom: 60px;
  }
  .content{
    width: 1200px;
    margin: auto;
  }
  .title{
    text-align: center;
    font-size: 32px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #1890FF;
    /*line-height: 84px;*/
    margin: 70px 0;
  }
  .news >>> .el-card{
    margin-bottom: 20px;
    padding: 10px;
  }
  .news img{
    border-radius: 10px;
    width: 100%;
  }
  .message{
    box-sizing: border-box;
    line-height: 28px;
  }
  .message p:nth-of-type(1){
    font-size: 22px;
    margin-bottom: 20px;
    color: #333333;
  }
  .message p:nth-of-type(2){
    font-size: 18px;
    margin-bottom: 40px;
    color: #999999;
  }
  .message p:nth-of-type(3){
    font-size: 16px;
    margin-bottom: 15px;
    color: #333333;
  }
</style>
